import { defineStore } from 'pinia';
import { LoginApi } from "@/api/Login";
let user = JSON.parse(localStorage.getItem("user")as string) || {};
export const useCategoryStore = defineStore({
    id:'Login',
    state:()=>({ 
        nickname:user.nickname,
        avatarUrl:user.avatarUrl,
    }),
    actions: {
      async LoginApi(phone:string,password:string){
       const {profile,token}=await LoginApi(phone,password);
        this.nickname=profile.nickname;
        this.avatarUrl=profile.avatarUrl;
        localStorage.setItem("user",JSON.stringify(profile))
        localStorage.setItem("token",JSON.stringify(token));
      }
    }
});